<template>
  <div>
    <h1>登录</h1>
    <van-field label="用户名" v-model="form.username"></van-field>
    <van-field label="密码" v-model="form.password"></van-field>
    <van-button @click="login">登录</van-button>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: "yd_login",
  data() {
    return {
      form:{},
    }
  },
  methods: {
    login() {
      axios.post('http://127.0.0.1:5000/yd_login', this.form)
      .then(res=>{
        console.log(res)
        localStorage.setItem('id',res.data.id)
        localStorage.setItem('username',res.data.username)
        localStorage.setItem('list1',JSON.stringify(res.data.list1))
        alert('登陆成功')
        this.$router.push('/news')
      })
    }
  },
  mounted() {
  }
}
</script>

<style scoped>

</style>
